 /**
  *  定义一个数组,里面存放学生数据
  * 1. 年龄最大的学生
  * 2. 返回每个班级的人数
  * 3. 输出一个编号,返回这个学生电话.返回的电话加密(1389****345)
  */

 //我们自己构造了一种新的数据类型 IUser
 interface IClasses {
    id:number,
    name:string
 }
 interface IUser {
    id:number,
    name:string,
    age:number,
    phone:string,
    classes:IClasses
 }
 let students:Array<IUser> = [
    {id:1,name:"xiaowang",phone:"13890012345",age:23,classes:{id:1,name:"web34"}},
    {id:2,name:"xiaofei",phone:"13890012345",age:24,classes:{id:2,name:"web33"}},
    {id:3,name:"xiaoliu",phone:"13890012345",age:25,classes:{id:2,name:"web33"}},
 ]

 function findStudent(stu:Array<IUser>):IUser | undefined{
    //temp = [23,24,25]
    const temp = stu.map(item=>{
        return item.age
    })
    const maxAge = Math.max.apply(temp)
    const student = stu.find(item=>item.age == maxAge)
    // if(student){
    //     return student
    // }else{
    //     return stu[0]
    // }
    return student
 }

